package com.situ.orderingsystem.service.impl;

import com.situ.orderingsystem.dao.EmployeeDao;
import com.situ.orderingsystem.dao.FoodDao;
import com.situ.orderingsystem.dao.impl.EmployeeDaoImpl;
import com.situ.orderingsystem.dao.impl.FoodDaoImpl;
import com.situ.orderingsystem.model.Employee;
import com.situ.orderingsystem.model.EmployeeSerchBean;
import com.situ.orderingsystem.model.Food;
import com.situ.orderingsystem.model.FoodSearchBean;
import com.situ.orderingsystem.service.FoodService;
import com.situ.orderingsystem.utils.BeanFactory;
import com.situ.orderingsystem.utils.PaginateInfo;

import java.util.List;

public class FoodServiceImpl implements FoodService {
    private final FoodDao dao = BeanFactory.getBean(FoodDaoImpl.class);

    @Override
    public List<Food> findAll(FoodSearchBean eb, PaginateInfo pi) {
        return dao.findAll(eb,pi);
    }
    public List<Food> findAll() {
        return dao.findAll();
    }
    public List<Food> comboList(){
        return  dao.findCombo();
    }
    @Override
    public int deleteByIds(Integer[] ids) {
        int rows=0;
        for(Integer id :ids){
            boolean b = dao.deleteById(id) ;
            if(b){
                rows++;
            }
        }
        return  rows;
    }

    @Override
    public boolean save(Food food) {
        return  dao.add(food) > 0;
    }

    @Override
    public Food searchById(Integer id) {
        return  dao.searchById(id);
    }

    @Override
    public boolean update(Food food) {
        return dao.update(food)  > 0;
    }
}
